<#include "/common/h-ui-base-css.html">
<#include "/common/h-ui-base-js.html">
<#include "/common/validation-js.html">
<#include "/common/cityPicker.html">


<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-menu-add">
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2" style="text-align: center"><span class="c-red">*</span>页面名称：</label>
			<div class="formControls col-xs-9 col-sm-10">
				<input type="text" class="input-text" value="${menu.menuName!}" placeholder="" id="menu_name" name="menu_name">
			</div>
		</div>
		<#if flag=='main'>
		    <div class="row cl">
                <label class="form-label col-xs-3 col-sm-2" style="text-align: center" ><span class="c-red">*</span>图标：</label>
                <div class="formControls col-xs-9 col-sm-10">
                    <input type="text" class="input-text" autocomplete="off" value="${menu.menuIcon!}" placeholder="" id="menu_icon" name="menu_icon">
                </div>
            </div>
		</#if>
		<#if flag=='son'>
		    <div class="row cl">
                <label class="form-label col-xs-3 col-sm-2" style="text-align: center" ><span class="c-red">*</span>路径：</label>
                <div class="formControls col-xs-9 col-sm-10">
                    <input type="text" class="input-text" autocomplete="off" value="${menu.menuURL!}" placeholder="" id="menu_url" name="menu_url">
                </div>
            </div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2" style="text-align: center" ><span class="c-red">*</span>父目录：</label>
                <div class="formControls col-xs-9 col-sm-9">
					<span class="select-box" style="width:420px;">
						<select class="select" name="menu_parent" id="menu_parent" size="1">
							<#if list??>
							    <#list list as list>
									<option value="${list.id}" <#if menu.parentId?? ><#if list.id==menu.parentId?number>selected</#if></#if>>${list.menuName}</option>
								</#list>
							</#if>
						</select>
					</span>
                </div>
			</div>
		</#if>
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
	</div>
	</form>
</article>
<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">
    var cityPicker = new IIInsomniaCityPicker({
        data: cityData,
        target: '#menu_icon',
        valType: 'k-v'
    });
    cityPicker.init();
</script>

<script type="text/javascript">
	$(function(){
        var id = ${menu.id!-1};
        var parentId = ${menu.parentId!0}
		$('.skin-minimal input').iCheck({
			checkboxClass: 'icheckbox-blue',
			radioClass: 'iradio-blue',
			increaseArea: '20%'
		});
	$("#form-menu-add").validate({
		rules:{
            menu_name:{
				required:true,
				minlength:2,
				maxlength:16
			},
            menu_icon:{
				required:true,
                minlength:2,
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
		    var pId = 1;
			$(form).ajaxSubmit({
				type: 'post',
				url: "/menu-save/"+id +'/'+parentId,
				data :$("form-menu-add").serialize(),
				async:false,
				success: function(data){
                    pId = data.parentId;
				},
                error: function(XmlHttpRequest, textStatus, errorThrown){
				}
			});
			var index = parent.layer.getFrameIndex(window.name);
            parent.$('#role_list_table').treegrid("reload",pId);
			parent.layer.close(index);
		}
	});

});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
